/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pa165.dominatingspecies.frontend.element;

import java.util.Arrays;
import java.util.List;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.model.IModel;

/**
 *
 * @author Ondrej Prazak
 */
public class EnumDropDown<T extends Enum<T>> extends DropDownChoice<T> {

    public EnumDropDown(String id, IModel<T> model) {
        super(id);
        setModel(model);
        setChoiceRenderer(new EnumChoiceRenderer(this));
    }

    public EnumDropDown(String id, IModel<T> model, EnumChoiceRenderer<T> choiceRenderer) {
        super(id);
        setModel(model);
        setChoiceRenderer(choiceRenderer);
    }

    @Override
    public List<? extends T> getChoices() {
        return Arrays.asList(getModelObject().getDeclaringClass().getEnumConstants());
    }
}
